package com.ys.web.sys.notice.task;

import com.ys.utils.spring.properties.Config;
import com.ys.web.sys.notice.service.NoticeService;
import com.ys.web.sys.notice.vo.SystemNoticeVo;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * @author quxinjun
 * @version 1.0.0
 * @ClassName CycleSystemNoticeTask.java
 * @Description TODO
 * @createTime 2022年01月21日 06:11:00
 */
@Component
public class CycleSystemNoticeTask implements Job {

    @Autowired
    private NoticeService noticeService;

    @Override
    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
        String notice = Config.pp.get("system.cycle.notice");
        if (notice != null) {
            SystemNoticeVo systemNoticeVo = new SystemNoticeVo();

            systemNoticeVo.setTitle("温馨提示");
            systemNoticeVo.setContent(notice);
            systemNoticeVo.setUserId(1L);
            systemNoticeVo.setIsAll(false);
            systemNoticeVo.checkParam();
            noticeService.addNotice(systemNoticeVo);
        }
    }

}
